/*
 * JobApplication.java
 *
 * Created on 11. Juni 2007, 05:05
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package sbc.corso;

import corso.lang.*;
import sbc.util.*;
import java.util.*;

/**
 *
 * @author mustermark
 */
public class JobApplication implements CorsoShareable {
    
    public final static String STRUCT_NAME = "APP";
    private CorsoVarOid oid;
    private String who, education, section;
    
    protected JobApplication() { }
    
    public JobApplication(String _who) {
        oid = new CorsoVarOid();
        who = _who;
    }

    public CorsoVarOid getOid() { return oid; }
    
    public String getApplicant() { return who; }
    
    public String getEducation() { return education; }
    
    public String getSection() { return section; }
    
    /**
   * Method which is called, if you read the structure from an oid
   *
   * @param data            CorsoData object from which the data is read
   *
   * @return                none
   *
   */
  public void read (CorsoData data) throws CorsoDataException
  {
    StringBuffer structName = new StringBuffer("");

    // first get the structure information ************************************
    int arity = data.getStructTag (structName);
    if (arity != 4)
    {
      System.out.println ("arity of data is " + arity);
      throw new CorsoDataException ();
    }

    // here we also check the name of the structure ***************************
    if (!structName.toString ().equals (STRUCT_NAME))
    {
      throw new CorsoDataException ();
    }

    // reading oid from data **************************************************
    who = data.getString();
    education = data.getString();
    section = data.getString();
    data.getShareable (oid);
  }

  /**
   * Method which is called, if you write the structure to an oid
   *
   * @param data            CorsoData object to which the data is written
   *
   * @return                none
   *
   */
  public void write (CorsoData data) throws CorsoDataException
  {
    // first put the structure information ************************************
    data.putStructTag (STRUCT_NAME, 4);

    // write oid to data ******************************************************
    data.putString(who);
    data.putString(education);
    data.putString(section);
    data.putShareable (oid);
  }
}
    

